package de.fuberlin.inf.alp3.ue02;

import java.awt.Color;
import java.awt.Graphics;

public class DrawableTheatre extends Theatre implements Drawable {
    public static final Color BLACK = new Color(0);
    public static final Color GREEN = new Color(200, 255, 200);
    public static final Color RED = new Color(255, 100, 100);
    public DrawableTheatre(int rows, int seats) { super(rows, seats); }

    @Override
    public void draw(Graphics g) {
        for (int i = 0; i < this.hall[0].length;)
            g.drawString(Integer.toString(++i), (i*20), 20);
        for (int i = 0; i < this.hall.length; i++) {
            g.drawString(Character.toString((char) (65+i)), 5, (i+2)*20);
            for (int j = 0; j < this.hall[i].length; j++) {
                g.drawRect((j+1)*20, 7 + (i+1) * 20, 17, 17);
                if (!this.hall[i][j])  g.setColor(GREEN);
                else                   g.setColor(RED);
                g.fillRect(1+(j+1)*20, 8 + (i+1) * 20, 16, 16);
                g.setColor(BLACK);
            }
        }
    }

    @Override
    public int getHeight() { return 80 + (this.getMaxRow() - 98) * 20; }

    @Override
    public int getWidth() { return 10 + (this.getMaxSeat() + 1) * 20; }

    public static void main(String[] args) {
        DrawableTheatre dt = new DrawableTheatre(8,16);
        new GUI("Kino 1, 20:15", dt);
    }
}